/*
* GeoVISTA Center (Penn State, Dept. of Geography)
* Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
* All Rights Researved.
*
*
* @author: jin Chen
* @date: Jun 16, 2003
* @version: $VERSION$
*/
package edu.psu.geovista.app.pcp.plot.control;


import edu.psu.geovista.app.pcp.plot.control.actions.SortOnCorrelation;
import epoviz.trex.common.swing.components.toolbar.ExpandableToolbar;

import javax.swing.*;

public class ToolBar extends JPanel{


    //BasicPcpUI ui;
    protected /*javax.swing.JToolBar */ ExpandableToolbar AnimationBar;
    protected javax.swing.JToolBar AxisBar;
    protected javax.swing.JToolBar DataBar;
    protected javax.swing.JToolBar operationModeBar;  //decide which operation(select, move axis...) is to apply
    protected javax.swing.JToolBar dataModeBar;//decide which data(rawdata, summary data...) is operated on
    protected javax.swing.JToolBar comBar;//common tool bar
    protected ActionMgr am;

    public ToolBar(ActionMgr am) {
        this.am=am;

        this.initComponents()  ;
    }
    protected  void initComponents() {
        setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));




        comBar = new javax.swing.JToolBar();
        comBar.setRollover(true);
        comBar.add(this.getButton("ShowRangeCfg"));
        comBar.add(this.getButton("OpenFile") );

        add(comBar);


        operationModeBar = new javax.swing.JToolBar();
        operationModeBar.setRollover(true);
        JButton HighlightDataBttn=this.getButton("Highlight") ;
        operationModeBar.add(HighlightDataBttn);
        add(operationModeBar);


        DataBar = new javax.swing.JToolBar();
        DataBar.setRollover(true);
        JButton showAllBttn=this.getButton(ActionMgr.ACTION_DATASHOWALL) ;
        JButton showInvalidBtn= this.getButton("DataShowInvalid") ;
        DataBar.add(showAllBttn);
       // DataBar.add(showPartialBttn);
        DataBar.add(showInvalidBtn);
        add(DataBar);


        dataModeBar=new JToolBar();
        dataModeBar.setRollover(true);
        JButton showMedianBtn=this.getButton(ActionMgr.ACTION_SHOWMEDIANSUMMRY);
        JButton showObBtn=this.getButton(ActionMgr.ACTION_ShowObsrvSumm);
        JButton NormalModeBtn=this.getButton(ActionMgr.ACTION_ShowNormal);
        dataModeBar.add(NormalModeBtn);
        dataModeBar.add(showMedianBtn);
        dataModeBar.add(showObBtn);
        add(dataModeBar);



        AnimationBar=new ExpandableToolbar();
        AnimationBar.setRollover(true);
        JButton startBttn=this.getButton("StartAnm") ;
        JButton stepBttn=this.getButton("StepAnm") ;
        JButton stopBttn=this.getButton("StopAnm") ;
        JButton pauseBttn=this.getButton("PauseAnm") ;
        AnimationBar.addButton(startBttn);
        AnimationBar.addButton(stepBttn);
        AnimationBar.addButton(pauseBttn);
        AnimationBar.addButton(stopBttn);
        AnimationBar.addControlButton();
        add(AnimationBar);


        AxisBar = new javax.swing.JToolBar();
        AxisBar.setRollover(true);
        JButton resetTickBttn=this.getButton("Reset") ;
        JButton AlignBoxplotBttn=this.getButton("AlignBoxplot") ;
        JButton ShowBoxPlotBttn=this.getButton("ShowBoxplot") ;
        JButton ShowCorrelationBttn=this.getButton("ShowCorrelation") ;
        JButton fitWindowBtn= this.getButton("FitWindow") ;
        JButton frmScanBtn = this.getButton("FrameScan");
        JButton screenShootBtn = this.getButton("ScreenShoot");
        String actionID = DfActionManager.getActionID(SortOnCorrelation.class);
        JButton sortCrbtn = this.getButton(actionID);

        AxisBar.add(ShowBoxPlotBttn);
        AxisBar.add(AlignBoxplotBttn);
        AxisBar.add(resetTickBttn);
        AxisBar.add(ShowCorrelationBttn);
        AxisBar.add(fitWindowBtn);

        AxisBar.add(sortCrbtn);
        //AxisBar.add(screenShootBtn);
        add(AxisBar);




    }
    /**
     * set some buttons in clicked state by default. It takes effect only if dataModel is set before
     * because if before dataModel is set, there is no Cmds available thus neither mouse listeners nor mouse reactor are
     * available.
     *
     * @see  ToolManager.processAction()
     */
    public void setDefault() {
        JButton SelectDataBttn=this.getButton("Select");
        SelectDataBttn.doClick() ;

    }
    //private void createButtons

    protected  JButton getButton(String name){
        final JButton button = am.getButton(name);

        return button;
    }

}
